﻿<UserControl x:Class="Microsoft.Research.ScientificWorkflow.WebClient.Views.WorkflowApplication.WorkAreaView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Width="Auto" Height="Auto" Margin="5"
             xmlns:basics="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             mc:Ignorable="d" xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls" 
             xmlns:controlsToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit" 
             xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
             xmlns:converters="clr-namespace:Microsoft.Research.ScientificWorkflow.WebClient.Common"
             xmlns:treeTemplate="clr-namespace:System.Windows;assembly=System.Windows.Controls">
    <UserControl.Resources>
        <converters:NullableBooleanToVisibilityConverter x:Key="boolToVisibilityConverter"></converters:NullableBooleanToVisibilityConverter>
        <converters:NegationConverter x:Key="oppositeVisibilityConverter"></converters:NegationConverter>
        <DataTemplate x:Key="DataproductTemplate">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding DataproductName}"/>
                <HyperlinkButton x:Name="hlbtnWorkflowOutputPreview" Content="Preview" Margin="5,0,0,0" Click="OnPreviewClick"/>
            </StackPanel>
        </DataTemplate>
    </UserControl.Resources>
	<basics:TabControl BorderBrush="#FFD4D4D4" x:Name="tabCenterpane" Style="{StaticResource TabControlStyle1}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
		<basics:TabControl.Background>
			<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
				<GradientStop Color="#FFFFFFFF"/>
				<GradientStop Color="#FFF9F9F9" Offset="1"/>
			</LinearGradientBrush>
		</basics:TabControl.Background>
		<basics:TabItem Header="Details" Style="{StaticResource TabItemStyle1}" x:Name="tabDetails">
			<Grid x:Name="detailsGrid" Visibility="Collapsed">
				<ScrollViewer HorizontalAlignment="Stretch" VerticalAlignment="Stretch" BorderBrush="{x:Null}" VerticalScrollBarVisibility="Auto">
					<StackPanel>
						<Border BorderBrush="#FFC8C8C8" BorderThickness="1,1,1,1" CornerRadius="5,5,5,5" Margin="5,10,5,0">
							<Grid>
								<Grid.RowDefinitions>
									<RowDefinition Height="25"/>
									<RowDefinition Height="*"/>
								</Grid.RowDefinitions>
								<Border HorizontalAlignment="Stretch" Margin="0,0,0,0" VerticalAlignment="Stretch" Grid.Row="0" CornerRadius="5,5,0,0">
									<Border.Background>
										<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
											<GradientStop Color="#FFFFFFFF" Offset="0"/>
											<GradientStop Color="#FFE8E8E8" Offset="1"/>
										</LinearGradientBrush>
									</Border.Background>
									<Grid>
										<Grid.ColumnDefinitions>
											<ColumnDefinition Width="*"/>
											<ColumnDefinition Width="28"/>
										</Grid.ColumnDefinitions>
										<TextBlock HorizontalAlignment="Stretch" VerticalAlignment="Center"  Margin="5,0,0,0" FontSize="13" x:Name="tbkWorkflowName"/>
												
									</Grid>
								</Border>
                                <Grid VerticalAlignment="Stretch" Grid.Row="1">
                                    <ScrollViewer Margin="5,5,2,5" Height="Auto" BorderBrush="{x:Null}" x:Name="scrollViewerContent" VerticalScrollBarVisibility="Disabled">
                                        <data:DataGrid x:Name="dataGridInputParameters" Width="Auto" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" AutoGenerateColumns="False" AlternatingRowBackground="White">
                                            <data:DataGrid.Columns>
                                                <data:DataGridTemplateColumn Header="Input Parameters">
                                                    <data:DataGridTemplateColumn.CellTemplate>
                                                        <DataTemplate>
                                                            <Grid>
                                                                <Grid.ColumnDefinitions>
                                                                    <ColumnDefinition Width="14"></ColumnDefinition>
                                                                    <ColumnDefinition></ColumnDefinition>
                                                                </Grid.ColumnDefinitions>
                                                                <Grid ToolTipService.ToolTip="Enter a valid value for the property." Margin="2,0,0,0" Width="12" Height="12" Visibility="{Binding IsValueInvalid, Converter={StaticResource boolToVisibilityConverter}}">
                                                                    <Ellipse Fill="#FFC42A2A" Stroke="{x:Null}"/>
                                                                    <Path Fill="#FFFFFFFF" Stretch="Fill" Stroke="{x:Null}" StrokeThickness="2" Margin="4.94,2.235,4.644,5.12" Data="M11.701627,8.0009042 L12.372672,15.173164 14.011686,15.241177 14.56827,7.8270056 z"/>
                                                                    <Path Fill="#FFFFFFFF" Stretch="Fill" Stroke="{x:Null}" StrokeThickness="2" Margin="5.121,0,4.779,1.746" VerticalAlignment="Bottom" Height="2.1" Data="M11.395564,17.238573 L14.853121,17.333691 14.771832,21.163108 11.102494,20.999791 z"/>
                                                                </Grid>
                                                                <TextBlock Grid.Column="1" Padding="5,0,5,0" Text="{Binding PropertyPaneDisplayName}" HorizontalAlignment="Stretch">
                                                                </TextBlock>
                                                            </Grid>
                                                        </DataTemplate>

                                                    </data:DataGridTemplateColumn.CellTemplate>
                                                </data:DataGridTemplateColumn>
                                                <data:DataGridTemplateColumn Header="Value">
                                                    <data:DataGridTemplateColumn.CellTemplate>
                                                        <DataTemplate>
                                                                <TextBox Padding="5,0,5,0" Text="{Binding Value}" IsEnabled="{Binding IsDatabound, Converter={StaticResource oppositeVisibilityConverter}}" LostFocus="OnLostFocus" HorizontalAlignment="Stretch"/>
                                                        </DataTemplate>
                                                    </data:DataGridTemplateColumn.CellTemplate>
                                                </data:DataGridTemplateColumn>
                                            </data:DataGrid.Columns>
                                        </data:DataGrid>
                                    </ScrollViewer>
                                </Grid>
                            </Grid>
						</Border>
						<Border BorderBrush="#FFC8C8C8" BorderThickness="1,1,1,1" CornerRadius="5,5,5,5" Margin="5,10,5,0">
							<Grid>
								<Grid.RowDefinitions>
									<RowDefinition Height="25"/>
									<RowDefinition Height="*"/>
								</Grid.RowDefinitions>
								<Border HorizontalAlignment="Stretch" Margin="0,0,0,0" VerticalAlignment="Stretch" Grid.Row="0" CornerRadius="5,5,0,0">
									<Border.Background>
										<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
											<GradientStop Color="#FFFFFFFF" Offset="0"/>
											<GradientStop Color="#FFE8E8E8" Offset="1"/>
										</LinearGradientBrush>
									</Border.Background>
									<Grid>
										<Grid.ColumnDefinitions>
											<ColumnDefinition Width="*"/>
										</Grid.ColumnDefinitions>
										<TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" Text="Job Details" Margin="5,0,0,0" FontSize="13"/>
									</Grid>
								</Border>
								<Grid HorizontalAlignment="Stretch" Margin="5,2,5,5" Grid.Row="1" Grid.RowSpan="1" Height="60">
									<Grid.RowDefinitions>
										<RowDefinition Height="30"/>
										<RowDefinition Height="30"/>
										<!--<RowDefinition Height="30"/>-->
										
									</Grid.RowDefinitions>
									<Grid.ColumnDefinitions>
										<ColumnDefinition Width="0.164*"/>
										<ColumnDefinition Width="0.836*"/>
									</Grid.ColumnDefinitions>
									<TextBlock Text="Job Name:" Grid.ColumnSpan="1" Grid.RowSpan="1" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,5,0"/>
									<TextBox HorizontalAlignment="Left" VerticalAlignment="Center" Text="" TextWrapping="Wrap" Grid.Column="1" Width="200" x:Name="tbxJobName" MaxLength="75"/>
									<TextBlock Text="Node:"  HorizontalAlignment="Right" VerticalAlignment="Center" Grid.Row="1" Margin="0,0,5,0"/>
                                    <ComboBox  HorizontalAlignment="Left" VerticalAlignment="Center" Grid.Row="1" Grid.Column="1" Width="200" x:Name="cboNode" Height="24">
                                        <ComboBox.ItemTemplate>
                                            <DataTemplate>
                                                <TextBlock Text="{Binding Path=NodeName}"></TextBlock>
                                            </DataTemplate>
                                        </ComboBox.ItemTemplate>
                                    </ComboBox>
								</Grid>
							</Grid>
						</Border>
						<Border BorderBrush="#FFC8C8C8" BorderThickness="1,1,1,1" CornerRadius="5,5,5,5" Margin="5,10,5,10">
							<Grid>
								<Grid.RowDefinitions>
									<RowDefinition Height="25"/>
									<RowDefinition Height="*"/>
								</Grid.RowDefinitions>
								<Border HorizontalAlignment="Stretch" Margin="0,0,0,0" VerticalAlignment="Stretch" Grid.Row="0" CornerRadius="5,5,0,0">
									<Border.Background>
										<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
											<GradientStop Color="#FFFFFFFF" Offset="0"/>
											<GradientStop Color="#FFE8E8E8" Offset="1"/>
										</LinearGradientBrush>
									</Border.Background>
									<Grid>
										<Grid.ColumnDefinitions>
											<ColumnDefinition Width="*"/>
										</Grid.ColumnDefinitions>
										<TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" Text="Notes" Margin="5,0,0,0" FontSize="13"/>
									</Grid>
								</Border>
								<StackPanel HorizontalAlignment="Stretch" Margin="5,2,5,5" Grid.Row="1" Grid.RowSpan="1">
									<TextBox TextWrapping="Wrap" MaxLength="300" VerticalScrollBarVisibility="Auto" Margin="0,2,5,2" Height="60" x:Name="tbxNotes"/>
								</StackPanel>
							</Grid>
						</Border>
					</StackPanel>
				</ScrollViewer>
			</Grid>
		</basics:TabItem>
		<basics:TabItem Header="Execution" Style="{StaticResource TabItemStyle1}" x:Name="tabExecution">
			<Grid x:Name="resultsGrid" Visibility="Collapsed">
				<ScrollViewer Margin="0,0,0,0" BorderBrush="{x:Null}">
					<StackPanel Margin="0,0,0,0">
						<controlsToolkit:Expander Style="{StaticResource ExpanderStyle1}" Header="Workflow Input Parameters" IsExpanded="True">
							<Grid>
								<Border BorderBrush="#FFC8C8C8" BorderThickness="1,0,1,1" CornerRadius="0,0,5,5" Grid.RowSpan="1" Margin="0,0,0,0">
                                    <Grid>
										<Grid.RowDefinitions>
											<RowDefinition Height="*"/>
										</Grid.RowDefinitions>
										<data:DataGrid x:Name="dgExecutionWorkflowInputs" 
											Height="160" Margin="5,5,5,5" 
											AutoGenerateColumns="False" IsReadOnly="true"> 
                                            <data:DataGrid.Columns>
                                                <data:DataGridTemplateColumn Header="Input Parameters">
                                                    <data:DataGridTemplateColumn.CellTemplate>
                                                        <DataTemplate>
                                                                <TextBlock Padding="5,0,5,0" Text="{Binding PropertyPaneDisplayName}" HorizontalAlignment="Stretch">
                                                                </TextBlock>
                                                        </DataTemplate>
                                                    </data:DataGridTemplateColumn.CellTemplate>
                                                </data:DataGridTemplateColumn>
                                                <data:DataGridTemplateColumn Header="Value">
                                                    <data:DataGridTemplateColumn.CellTemplate>
                                                        <DataTemplate>
                                                                <TextBlock Padding="5,0,5,0" Text="{Binding Value}" HorizontalAlignment="Stretch"/>
                                                        </DataTemplate>
                                                    </data:DataGridTemplateColumn.CellTemplate>
                                                </data:DataGridTemplateColumn>
                                            </data:DataGrid.Columns>
                                        </data:DataGrid>
									</Grid>
								</Border>
							</Grid>
						</controlsToolkit:Expander>
						<controlsToolkit:Expander Style="{StaticResource ExpanderStyle1}" Header="Workflow Output Parameters" IsExpanded="True" Margin="0,10,0,0">
							<Grid>
								<Border Height="180" BorderBrush="#FFC8C8C8" BorderThickness="1,0,1,1" CornerRadius="0,0,5,5" Grid.RowSpan="1" Margin="0,0,0,0">
                                        <data:DataGrid x:Name="WorkflowOuputsList" 
											Height="160" Margin="5,5,5,5" 
											AutoGenerateColumns="False" IsReadOnly="true"> 
                                            <data:DataGrid.Columns>
                                                <data:DataGridTextColumn Width="160" Binding="{Binding DisplayName}" Header="Parameter"></data:DataGridTextColumn>
                                                <data:DataGridTemplateColumn Header="Workflow Output">
                                                    <data:DataGridTemplateColumn.CellTemplate>
                                                        <DataTemplate>
                                                            <StackPanel Orientation="Horizontal">
                                                                <TextBlock Text="{Binding DataproductName}"/>
                                                                <HyperlinkButton x:Name="hlbtnWorkflowOutputPreview" Content="Preview" Margin="5,0,0,0" Click="OnPreviewClick"/>
                                                            </StackPanel>
                                                        </DataTemplate>
                                                    </data:DataGridTemplateColumn.CellTemplate>
                                                </data:DataGridTemplateColumn>
                                            </data:DataGrid.Columns>
                                            
                                        </data:DataGrid>
							</Border>
							</Grid>
						</controlsToolkit:Expander>
						<controlsToolkit:Expander Style="{StaticResource ExpanderStyle1}" Header="Data Products" IsExpanded="True" Margin="0,10,0,0">
							<Grid>
								<Border Height="160" BorderBrush="#FFC8C8C8" BorderThickness="1,0,1,1" CornerRadius="0,0,5,5" Grid.RowSpan="1">
                                        <controls:TreeView x:Name="dataproductsTree" Margin="5" BorderBrush="Transparent">
                                            <controls:TreeView.ItemTemplate>
                                                <treeTemplate:HierarchicalDataTemplate ItemTemplate="{StaticResource DataproductTemplate}" ItemsSource="{Binding DataProducts}">
                                                    <Grid>
                                                        <Grid.ColumnDefinitions>
                                                            <ColumnDefinition Width="21.5"/>
                                                            <ColumnDefinition Width="*" MinWidth="26.098"/>
                                                        </Grid.ColumnDefinitions>
                                                        <Image Grid.ColumnSpan="1" Width="16" Source="../../Images/DataStoreICon.png" HorizontalAlignment="Center" VerticalAlignment="Center" Height="16">
                                                           
                                                        </Image>
                                                        <TextBlock Grid.Column="1" Margin="1,0,0,0" Text="{Binding Path=ActivityName}"/>
                                                    </Grid>
                                                </treeTemplate:HierarchicalDataTemplate>
                                            </controls:TreeView.ItemTemplate>
                                        </controls:TreeView>
								</Border>
							</Grid>
						</controlsToolkit:Expander>
					</StackPanel>
				</ScrollViewer>
			</Grid>
		</basics:TabItem>
	</basics:TabControl>
</UserControl>
